import DetailContainer, { Title } from "@/components/DetailContainer";
import { getUserDetail } from "@/services/user";
import { useParams } from "@umijs/max";
import { Col, Descriptions, Row } from "antd";
import { useEffect, useState } from "react";

const UseUserDetail = () => {
  const { id } = useParams() || {};
  const [data, setData] = useState<Types.User.IUserInfo>();

  const getUserDetailFun = async () => {
    let resp = await getUserDetail({ id } as { id: string });
    if (resp.code === 1) {
      setData(resp.data);
    }
  };

  useEffect(() => {
    getUserDetailFun();
  }, []);

  return (
    <DetailContainer>
      <Title>基本信息</Title>
      <Row>
        <Col>
          <Descriptions column={2}>
            <Descriptions.Item label="ID">{data?.id}</Descriptions.Item>
            <Descriptions.Item label="名字">{data?.name}</Descriptions.Item>
            <Descriptions.Item label="创建时间">{data?.create_time}</Descriptions.Item>
          </Descriptions>
        </Col>
      </Row>
    </DetailContainer>
  );
};

export default UseUserDetail;
